<?php

App::uses('AppController', 'Controller');

class ProizvodiController extends AppController {
    
    public $uses = array('Group', 'Product');
    
    public function index($groupName=null, $groupId=null) {
        $group    = $this->Group->get($groupId);
        $products = array();
        if (! empty($group)) {
            $this->pageTitle = $group['Group']['name'];
            $products = $this->paginate('Product', array('Product.group_id' => $group['Group']['id']));
        }
        
        $this->set(compact('group', 'products'));
    }
    
    public function view($id) {
        $this->set('data', $this->Product->findById($id));
    }
    
}